/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entity;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author atap
 */
@Entity
@Table(name = "commentrates", catalog = "spring2013g1", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Commentrates.findAll", query = "SELECT c FROM Commentrates c"),
    @NamedQuery(name = "Commentrates.findById", query = "SELECT c FROM Commentrates c WHERE c.id = :id"),
    @NamedQuery(name = "Commentrates.findByUserId", query = "SELECT c FROM Commentrates c WHERE c.userId = :userId"),
    @NamedQuery(name = "Commentrates.findByPoint", query = "SELECT c FROM Commentrates c WHERE c.point = :point")})
public class Commentrates implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "Id")
    private Integer id;
    @Basic(optional = false)
    @Column(name = "UserId")
    private int userId;
    @Column(name = "Point")
    private Integer point;
    @JoinColumn(name = "Id", referencedColumnName = "Id", insertable = false, updatable = false)
    @OneToOne(optional = false)
    private Comments comments;

    public Commentrates() {
    }

    public Commentrates(Integer id) {
        this.id = id;
    }

    public Commentrates(Integer id, int userId) {
        this.id = id;
        this.userId = userId;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public int getUserId() {
        return userId;
    }

    public void setUserId(int userId) {
        this.userId = userId;
    }

    public Integer getPoint() {
        return point;
    }

    public void setPoint(Integer point) {
        this.point = point;
    }

    public Comments getComments() {
        return comments;
    }

    public void setComments(Comments comments) {
        this.comments = comments;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Commentrates)) {
            return false;
        }
        Commentrates other = (Commentrates) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entity.Commentrates[ id=" + id + " ]";
    }
    
}
